package com.example.emos.wx.controller;

import com.example.emos.wx.common.util.R;
import com.example.emos.wx.controller.form.SayHelloForm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @ClassName TestController
 * @Author zhangzhixi
 * @Description
 * @Date 2022/8/18 10:59
 * @Version 1.0
 */
@RestController
@RequestMapping("/test")
@Api("测试接口")
public class TestController {

    @Value("${emos.recieveNotify}")
    private String recieveNotify;

    @GetMapping("/test")
    @ApiOperation("测试方法1")
    public R testValue(){
        System.out.println("111");
        return R.ok(recieveNotify);
    }

    @PostMapping("/sayHello")
    @ApiOperation("测试方法")
    public R test(@Valid @RequestBody SayHelloForm form) {
        return R.ok().put("msg", "hello" + form.getName());
    }

    @PostMapping("/addUser")
    @ApiOperation("添加用户")
    @RequiresPermissions(value = {"ROOT", "USER:ADD"}, logical = Logical.OR)
    public R addUser() {
        return R.ok("用户添加成功");
    }
}
